<?php
class Language
{
	public function construct()
	{
		
	}
	
	public function index()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile('model/Language.php');		
		$smarty = new Smarty();
		$modLanguage = new ModelLanguage();
		$lang_arr = $modLanguage->getLanguageText();
		$smarty->assign("title", "Language Management");	
		$smarty->assign('lang_arr', $lang_arr);
		$smarty->display('language/index.tpl');
	}
	
	public function editLang()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile('model/Language.php');	
		$smarty = new Smarty();
		$modLanguage = new ModelLanguage();
		$request = CommonFunc::getRequest();
		$request_arr = explode("/", $request['url']);
		$id = $request_arr[2];
		$lang = $request_arr[3];
		$content_arr = $modLanguage->getLanguageTextById($id);
		
		if($lang == 'en')
		{
			$content = $content_arr['en_text'];
		} else if ($lang == 'sin') {
			$content = $content_arr['sin_text'];
		} else if ($lang == 'tamil') {
			$content = $content_arr['tamil_text'];
		}
		
		$keytext = $content_arr['en_text'];
		
		$smarty->assign("title", "Edit Language");	
		$smarty->assign('content', $content);
		$smarty->assign('keytext', $keytext);
		$smarty->assign('id', $id);
		$smarty->assign('lang', $lang);
		$smarty->display(ADMINTPL . 'language/editlang.tpl');
	}
	
	public function updateLanguage()
	{
		CommonFunc::loadFile(SMARTYLIBS . "Smarty.class.php");
		CommonFunc::loadFile('model/Language.php');	
		$smarty = new Smarty();
		$modLanguage = new ModelLanguage();
		
		$requeat = CommonFunc::getRequest();
		$modLanguage->updateLanguage($requeat);
	}
	
}	
?>